DevForce Help Reference
EntitySpan Constructor(EntityRelationLink[])
Example 


One or more entity relation links
Initializes a new instance of the EntitySpan class.
Syntax
'Declaration
 
Public Function New( _
   ByVal ParamArray entityRelationLinks() As EntityRelationLink _
)
'Usage
 
Dim entityRelationLinks() As EntityRelationLink
 
Dim instance As New EntitySpan(entityRelationLinks)
public EntitySpan( 
   params EntityRelationLink[] entityRelationLinks
)

Parameters

entityRelationLinks
One or more entity relation links
Exceptions
ExceptionDescription
System.ArgumentExceptionThrown if the relationships do not connect
Remarks
A single EntitySpan represents the relations among a graph of entities. You must be able to "walk" the spans without jumping or backtracking.

The EntitySpan is used in retrieving an entity graph with EntityManager.FindEntityGraph

Example
public void FindEntityGraph() {

  DomainModelEntityManager mgr = new DomainModelEntityManager();
  
  // Preload some data into cache for this example.
  var emp = mgr.Employees.Where(e => e.Id == 1).Include("OrderSummaries.OrderDetails.Product").ToList().First();

  // Get an order for this example.
  OrderSummary anOrder = mgr.FindEntities<OrderSummary>(EntityState.Unchanged).First();


  // Now retrieve an object graph for the selected order.
  var roots = new List<Entity> { anOrder };

  // Add spans - we want a) employee for the order, and b) order details and their products.
  // This requires 2 spans.
  EntitySpan span1 = new EntitySpan(EntityRelations.FK_OrderSummary_Employee.ToRole1Link);
  EntitySpan span2 = new EntitySpan(EntityRelations.FK_Order_Details_Orders.ToRole2Link,
    EntityRelations.FK_Order_Details_Products.ToRole1Link);
  var spans = new List<EntitySpan> { span1, span2 };

  // Get entity graph.
  var entityGraph = mgr.FindEntityGraph(roots, spans, EntityState.Unchanged);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntitySpan Class
EntitySpan Members
Overload List

Send Feedback